package cn.dlc.com.config;

import lombok.extern.slf4j.Slf4j;
import org.apache.rocketmq.spring.annotation.ConsumeMode;
import org.apache.rocketmq.spring.annotation.MessageModel;
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.apache.rocketmq.spring.core.RocketMQListener;
import org.springframework.stereotype.Service;

/**
 * @author 邓立川
 * @date 2021/1/10 10:49
 * @desc 消费消息，同时发送短信
 */
@Service
@Slf4j
// consumerGroup：消费者组名 topic：要消费的主题，可以是*
//@RocketMQMessageListener(consumerGroup = "consumer-group",topic = "order-topic")
// 测试事务消息，指定topic为 tx_topic
@RocketMQMessageListener(
        consumerGroup = "consumer-group",
        topic = "tx_topic",
        // CONCURRENTLY同步消费（默认），orderly（顺序消费）
        consumeMode = ConsumeMode.CONCURRENTLY,
        // BROADCASTING广播模式，CLUSTERING(集群模式，默认)
        messageModel = MessageModel.BROADCASTING
        )
public class SmsService implements RocketMQListener<String> {

    @Override
    public void onMessage(String order) {
        log.info("接收到消息：{}",order);
    }
}
